package homework;

public class LuckyNumber {
    public  void method() {
        // 10(a+b)=160-(c+d)
        // a+b得15
        //a，b，c，d 范围是1<=   =<9
        for (int a = 6; a <= 9; a++) {
            int b = 15 - a;
            for (int c = 1; c <= 9; c++) {
                int d = 10 - c;
                // 计算F(M) = 21a + b -24c + 2d +16
                int F = 21 * a + b - 24 * c + 2 * d + 16;
                // 检查F是否被17整除且F+26是平方数
                if (F % 17 == 0) {
                    int temp = F + 26;
                    if (temp >= 0) {
                        //开方取整
                        int sqrt = (int) Math.sqrt(temp);
                        if (sqrt * sqrt == temp) {
                            int M = a * 1000 + b * 100 + c * 10 + d;
                            System.out.println("满足条件的M值为：" + M);
                        }
                    }
                }
            }
        }
    }
}